import Vue from 'vue'
import Router from 'vue-router'
import {store} from '@/store/index'
import {deepCopy} from '@/utils/tools'

/* pages */

// 主容器
const home = () => import('@/pages/home/index.vue')

// 登录
const signIn = () => import('@/pages/sign_in/index.vue')

// 车险管理
const carManage = () => import('@/pages/car_manage/index.vue')

// 非车险管理
const nonAutoInsurance = () => import('@/pages/non_auto_insurance/index.vue')

// 组织管理
const organizationManage = () => import('@/pages/organization_manage/index.vue')

// 部门人员审核
const auditingMange = () => import('@/pages/auditing_manage/index.vue')

// 系统首页
const sysIndex = () => import('@/pages/sys_index/index.vue')


Vue.use(Router)

let router:any = new Router({
  routes: [
    {
      path: '/',
      redirect: '/sign-in'
    },
    {
      path: '/home',
      name: 'home',
      redirect: '/home/car-manage',
      component: home,
      children: [ 
        {
          path: 'sys-index',
          name: 'sysIndex',
          component: sysIndex
        },
        {
          path: 'car-manage',
          name: 'carManage',
          component: carManage,
          beforeEnter (to, from, next){

            // 设置部门组件选择类型(判断是否加载 新建等方法)
            store.commit('organizationStore/organizationSelectDisabledSwitch', false )
            
            next()
          }
        },
        {
          path: 'non-auto-insurance',
          name: 'nonAutoInsurance',
          component: nonAutoInsurance
        },
        {
          path: 'organization-manage',
          name: 'organizationManage',
          component: organizationManage,
          beforeEnter (to, from, next){
            store.commit('organizationStore/organizationSelectDisabledSwitch', true )
            next()
          }
        },
        {
          path: 'auditing-manage',
          name: 'auditingMange',
          component: auditingMange
        }
        
      ]
    },
    {
      path: '/sign-in',
      name: 'sign-in',
      component: signIn 
    }
  ]
});


export default router